{% extends "lbforum/base.html" %}

{% load lbforum %}

{% block title %}{{  block.super }}{% endblock %}

{% block extra_header %}
    <link rel="stylesheet" type="text/css" media="screen" href="/css/markitup/skins/markitup/style.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="/css/markitup/bbcode/style.css" />
{% endblock %}

{% block content %}
    <div id="actionbox">
    </div>  
    <div id="brd-wrap" class="brd">
        <div id="brd-viewforum" class="brd-page paged-page">
            {% include 'lbforum/inc_header.html' %}
            {% include 'lbforum/inc_announce.html' %}

            <div class="hr"><hr /></div>

            <div class="crumbs gen-content" id="brd-crumbs-top">
                {% include 'lbforum/inc_new_post_brd_crumbs.html' %}
            </div>
            <div class="main-wrapper" id="brd-main">
                <div class="main-head">
                    <h1 class="hn"><span>
                    {% if is_new_post %}
                    	<!--  {% trans "Post new"%}-->发布
                    {% else %}
                    	{% trans "Edit"%}
                    {% endif %}
                    <!--  {{ post_type }}-->帖子</span></h1>
                </div>
                {% if preview %}
                    <div class="main-subhead">
                        <h2 class="hn"><span><!--  {% trans "Preview your"%}-->预览{% if is_new_post %}{% trans "new" %}{% else %}<!--{% trans "edited"%}-->{% endif %}<!--  {{ post_type }}-->帖子</span></h2>
                    </div>
                    <div class="main-content main-frm" id="post-preview">
                        <div class="post singlepost">
                            <div class="posthead">
                                <h3 class="hn"><span class="post-num">#</span> <span class="post-byline"><span>{% trans "Topic by" %}</span><strong>{{ user.username }}</strong></span> <span class="post-link">{% now "Y-m-d H:i" %}</span></h3>
                            </div>
                            <div class="postbody">
                                <div class="post-entry">
                                    <div class="entry-content">
                                        <p>{{form.cleaned_data.message|bbcode|safe}}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif %}
                <div class="main-subhead">
                    <h2 class="hn"><span>{% trans "Compose and post your"%}{% if is_new_post %}{% trans "new"%}{% else %}<!-- {% trans "edited"%} -->{% endif %}<!--  {{ post_type }}-->帖子</span></h2>
                </div>
                <div class="main-content main-frm" id="post-form">
                	<!--  
                    <p class="ct-options options">You may use: <span class="item1"><a title="Help with: BBCode" href="http://fluxbb.org/forums/help/bbcode/" class="exthelp">BBCode</a></span> <span><a title="Help with: Images" href="http://fluxbb.org/forums/help/img/" class="exthelp">Images</a></span> <span><a title="Help with: Smilies" href="http://fluxbb.org/forums/help/smilies/" class="exthelp">Smilies</a></span></p>
                    -->
                    {% if form.errors %}
                        <div class="ct-box error-box" id="req-msg">
                            <p class="errornote"> {% trans "Please correct the errors below" %}.  </p>
                            {{ form|form_all_error }}
                        </div>
                    {% endif %}
                    <form action="" accept-charset="utf-8" method="post" class="frm-form" id="afocus">
                        <div class="hidden" id="hidden_fields">
                            { % csrf_token % } 
                        </div>
                        <fieldset class="frm-group group1">
                            <legend class="group-legend"><strong>Required information</strong></legend>
                            {% if show_subject_fld %}
                                <div class="sf-set set1">
                                    <div class="sf-box text required longtext">
                                        <label for="id_subject"><span>{% trans "Subject"%}: <em>({% trans "Required"%})</em></span></label><br/>
                                        <span class="fld-input">
                                            {{form.subject}}
                                        </span>
                                    </div>
                                </div>
                            {% endif %}
                            <div class="txt-set {% if topic %}set1{% else %}set2{% endif %}">
                                <div class="txt-box textarea required">
                                    <label for="id_message"><span>{% trans "reply content"%}: <em>({% trans "Required" %})</em></span></label>
                                    <div class="txt-input"><span class="fld-input">
                                            {{form.message}}
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <!--  
                            <fieldset class="mf-set set3">
                                <legend><span>Optional post settings:</span></legend>
                                <div class="mf-box checkbox">
                                    <div class="mf-item">
                                        <span class="fld-input"><input type="checkbox" value="1" name="hide_smilies" id="fld3"/></span> 
                                        <label for="fld3">Never show smilies as icons (images) for this post.</label>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset class="mf-set set4">
                                <legend><span>Attachments:</span></legend>
                                <div class="mf-box checkbox">
									<div class="mf-item">
										<button id="upload_button">Upload</button>
										<ul id="uploaded_files">
										</ul>
									</div>
                                </div>
                            </fieldset>
                            -->
                        </fieldset>
                        <div class="frm-buttons">
                            <span class="submit"><input type="submit" value="{% trans "Submit topic"%}" name="submit"/></span>
                            <!-- <span class="submit"><input type="submit" value= "{% trans "Preview topic"%}""预览" name="preview"/></span>-->
                            <span class="submit"><input type="submit" value= "预览" name="preview"/></span>
                        </div>
                    </form>
                </div>
                {% if first_post %}
                    <div class="main-subhead">
                        <h2 class="hn"><span>{% trans "Topic review (newest first)"%}</span></h2>
                    </div>
                    <div class="main-content main-frm" id="topic-review">
                        <div class="post firstpost lastpost">
                            <div class="posthead">
                                <h3 class="hn post-ident">
                                    <span class="post-num">1</span> <span class="post-byline"><span>Post by </span><strong>{{ first_post.posted_by.username }}</strong></span> 
                                    <span class="post-link">{{ first_post.created_on|timesince }}</span>
                                </h3>
                            </div>
                            <div class="postbody">
                                <div class="post-entry">
                                    <div class="entry-content">
                                        <p>{{ first_post.message|bbcode|safe }}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif %}
            </div>
            <div class="crumbs gen-content" id="brd-crumbs-end">
                {% include 'lbforum/inc_new_post_brd_crumbs.html' %}
            </div>
            <div class="hr"><hr /></div>
            {% include 'lbforum/inc_copyright.html' %}
        </div>
    </div>

    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/markitup/jquery.markitup.js"></script>
    <script type="text/javascript" src="/js/markitup/bbcode/set.js"></script>
    <script type="text/javascript" src="/js/ajaxupload.js"></script>
    <script type="text/javascript" src="/js/simple_tpl.js"></script>
    <script type="text/javascript" src="/js/upload_attachment.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
    <script type="text/javascript">
        mySettings['previewParserPath']='{% url markitup_preview %}';
        mySettings['previewAutoRefresh']=false;
	    $("#id_message").markItUp(mySettings);
        url_attachments_ajax_change_descn = "{% url attachments_ajax_change_descn %}";
        url_attachments_ajax_delete = "{% url attachments_ajax_delete %}";
        url_attachments_ajax_upload = "{% url attachments_ajax_upload %}";
        $().ready(function() {
            {% for o in unpublished_attachments %}
            add_attachment({'id': '{{o.id}}','url': '{{o.file.url}}','fn': '{{o.org_filename}}','descn':'{{o.description}}'});
            {% endfor %}
        });
    </script>
    <script type="text/html" id="attachment_li_tmpl">
        <li id="attachment_<%=id%>" class="nb">
        <a class="filename" href="<%=url%>" target="_blank"><%=fn%></a>
        <span class="icon descn" style="">&nbsp;</span>
        <span style="display: none;">
        <input class="fld-descn" value="<%=descn%>"/>
        <a class="submit-descn" href="#">submit</a>
        </span>
        <span class="icon remove">&nbsp;</span>
        <span class="icon insert">&nbsp;</span>
        <span class="ext">&nbsp;</span>
        </li>
    </script>
{% endblock %}
